﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;


namespace WssEvents
{
    public class GlobalEventListener : MonoBehaviour
    {
        [SerializeField]private string EVENT_NAME = "DefaultEvent";

        public UnityEvent events;

        private void OnEnable()
        {
            // MessageCenter.Instance.On(EVENT_NAME+eventTag,OnMessageReceive);
            GlobalEvent.Addlistener(EVENT_NAME, OnMessageReceive);
        }

        private void OnDisable()
        {
            // MessageCenter.Instance.Off(EVENT_NAME+eventTag,OnMessageReceive);
            GlobalEvent.Removelistener(EVENT_NAME, OnMessageReceive);
        }

        private void OnMessageReceive()
        {
            events?.Invoke();
        }
    }

}

